﻿using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using LinnerToolkit.Desktop.ModernUI.Mvvm;
using LinnerToolkit.Desktop.ModernUI.Navigation;
using SimulationPTSystem.DAL;
using System.Windows;
using System.Windows.Input;

namespace SimulationPTSystem.Evaluation.ViewModels
{
    public class MainPageViewModel : ModernViewModelBase
    {
        public ICommand StartCommand { get; }

        public ICommand CloseCommand { get; }

        public MainPageViewModel(IModernNavigationService navigationService) : base(navigationService)
        {
            StartCommand = new RelayCommand(obj =>
              {
                  var currentTrainingTeamInfo = SimulationPTDAL.GetCurrentTrainingTeamInfo();
                  if (currentTrainingTeamInfo == null)
                  {
                      ModernDialog.ShowMessage("当前没有正在训练的团队", "提示", System.Windows.MessageBoxButton.OK);
                      return;
                  }

                  navigationService.NavigateTo("TrainingPage", currentTrainingTeamInfo);
              });

            CloseCommand = new RelayCommand((obj) =>
              {
                  Application.Current.Shutdown();
              });
        }
    }
}
